<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="sf" uri="http://www.springframework.org/tags/form" %>


<html>
<head>
    <title>Edit contact</title>
    <script src="<c:url value='/static/jquery/jquery-1.7.2.js'/>"></script>
    <script src="<c:url value='/static/jquery/jquery.dataTables.js'/>"></script>
    <style type="text/css">@import "<c:url value='/static/css/demo_table.css'/>";</style>
    <style type="text/css">
        body {
            text-align: center;
            background: #dcdcdc;
        }

        #numbers {
            position: relative;
            margin-left: 60%;
        }
    </style>

    <script type="text/javascript">
        var numbers;
        //        $(document).ready(function() {
        $(function() {
            numbers = $('#numbers').dataTable({
                "bRetrieve": false,
                "bDestroy": true,
                "bProcessing": true,
                sSearch:false,
                bPaginate:false,
//                "bServerSide": true,
                "bJQueryUI": true,
                "sAjaxSource": "viewcontactajax.html?idContact=" + ${formatDataDto.id}
            });
//            numbers.fnDeleteRow(true);
        });
        function deleteNumber(idDet, idContact) {
//            var det = idDet;
//            var cont = idContact;
            $(document).ready(function() {
                $('#numbers').dataTable({
//                numbers.dataTable({
                    "bRetrieve": false,
                    "bDestroy": true,
                    "bProcessing": true,
                    bPaginate:false,
//                    "bServerSide": true,
                    "bJQueryUI": true,
//                    "data":"idDet=" + idDet + "&idContact=" + idContact,
                    "sAjaxSource": "deletenumberajax.html?idDet=" + idDet + "&idContact=" + idContact
                });

            });
        }
    </script>


</head>

<body>

<center>

    <h1>Редактируем контакт ${formatDataDto.firstName} ${formatDataDto.lastName}</h1>
    <sf:form method="POST" modelAttribute="formatDataDto">


        <table cellspacing="10" cellpadding="10" border="0">
            <tr>
                <td>
                    <label for="firstName">Имя:</label>
                </td>
                <td>
                    <sf:input path="firstName" size="15" id="firstName"/><br/>
                    <small id="firstName_msg">от 3 до 5 символов</small>
                    <br/>
                    <sf:errors path="firstName" cssClass="error"/>
                </td>
            </tr>
            <tr>
                <td>
                    <label for="lastName"><spring:message code="page.users.link"/>Фамилия:</label>
                </td>
                <td>
                    <sf:input path="lastName" size="15" id="lastName"/> <br/>
                    <small id="lastname_msg">от 3 до 5 символов</small>
                    <br/>
                    <sf:errors path="lastName" cssClass="error"/>
                </td>
            </tr>
        </table>

        <input type="submit" value="изменить"/>
        <br/><br/><br/><br/>

        <table id="numbers" border="1">
            <thead>
            <tr>
                <th>Тип</th>
                <th>Номер</th>
                    <%--<th>ID номера</th>--%>
                <th>&nbsp;</th>
                <th>&nbsp;</th>
            </tr>
            </thead>
            <tbody></tbody>
        </table>


        <%--<table id="datatable" border="1">--%>
        <%--<thead>--%>
        <%--<tr>--%>
        <%--<td>тип</td>--%>
        <%--<td>номер</td>--%>
        <%--<td>&nbsp;</td>--%>
        <%--<td>&nbsp;</td>--%>
        <%--</tr>--%>
        <%--</thead>--%>
        <%--<tbody>--%>
        <%--<c:forEach items="${formatDataDto.contactTelDetails}" var="detail">--%>
        <%--<tr>--%>
        <%--<td>--%>
        <%--${detail.telType}--%>
        <%--</td>--%>
        <%--<td>--%>
        <%--${detail.telNumber}--%>
        <%--</td>--%>
        <%--<td><a href="editnumber.html?idNumber=${detail.id}&id=${formatDataDto.id}">править</a></td>--%>
        <%--<td><input type="button"--%>
        <%--onClick="if (window.confirm('Вы действительно хотите удалить номер  ${detail.telNumber} ?')){deleteNumber(${formatDataDto.id},${detail.id} )}"--%>
        <%--value="удалить">--%>

        <%--</td>--%>

        <%--</tr>--%>

        <%--</c:forEach>--%>
        <%--</tbody>--%>
        <%--</table>--%>

    </sf:form>
    <a href="addnumber.html?idContact=${formatDataDto.id}">добавить еще один номер</a>
    <br/><br/><br/>
    <a href="contacts.html">Перейти к списку контактов</a>
    <br/><br/>


    <%--<input type="hidden" name="idContact" value="${formatDataDto.id}">--%>
</center>

</body>

</html>
